package com.example.zhunongzonghe.controller;


import com.example.zhunongzonghe.beans.ZnPostLikeBean;
import com.example.zhunongzonghe.common.Result;
import com.example.zhunongzonghe.service.ZnPostLikeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.security.Principal;

@RestController
@RequestMapping("/znPostLike")
public class ZnPostLikeController {
    @Autowired
    ZnPostLikeService znPostLikeService;

    /**
     * 用户点赞帖子
     * @param znPostLikeBean
     * @return
     */
    @RequestMapping("/postLike")
    public Result postLike(@RequestBody ZnPostLikeBean znPostLikeBean, Principal principal){
        System.out.println("11111"+ znPostLikeBean);
        if (znPostLikeBean==null) return new Result(false,"数据异常",400);
        znPostLikeService.addLike(znPostLikeBean,principal.getName());
        return new Result(true,"点赞成功",200);
    }
}
